package main

import "fmt"

func main() {
	var res float64
	res = operate(1, 2.0, '+')
	fmt.Println("res =", res)
}

func operate(n1 float64, n2 float64, operator byte) (float64) {
	
	var res float64
	switch operator {
	case '+':
		res = n1 + n2
	case '-':
		res = n1 - n2
	case '*':
		res = n1 * n2
	case '/':
		res = n1 / n2
	default:
		fmt.Println("错误")
	}
	return res
}